/*
 * @Author: yao
 * @Date: 2024-11-21 15:52:42
 * @LastEditTime: 2024-11-25 16:13:50
 * @LastEditors: yao
 * @Description:
 * @FilePath: \element-plus-vite-starter-main\src\stores\modules\AI.ts
 */
import { defineStore } from "pinia";

enum EntityType {
  "normal" = "normal",
  "question" = "question",
  "error" = "error",
  "loading" = "loading",
  "sleep" = "sleep",
  "success" = "success",
}
const lifeTime = 5000;
export const useAIStore = defineStore("AI", {
  state: () => {
    return {
      speaker: {
        state: EntityType.normal, //
        type: "text",
        content: "你好啊",
        link: "",
      },
    };
  },
  actions: {
    resetState() {
      this.$reset();
    },
    setContent(
      val,
      lastTime = lifeTime,
      state = EntityType.normal,
      type = "text",
      link = ""
    ) {
      this.speaker.content = val;
      this.speaker.state = state;
      this.speaker.type = type;
      this.speaker.link = link;
      if (lastTime !== -1) {
        let intervalId = setInterval(() => {
          this.resetState();
          clearInterval(intervalId);
        }, lastTime || lifeTime);
      }
    },
  },
});
// "info(系统太久未操作：你特么会不会用我？、休息一下喝口茶吧、欢迎回来我得朋友、你的某些定时任务ok就绪了、最新定时任务的进度、公告)",
//   "error(请求失败、)",
//   "success（请求时间很短、登录次数很多爱上我、请求失败表示是后端的问题和前端没关系、查询当日黄历、表单提交成功）",
//   "warning（点击太多次菜单，询问是否需要帮忙查找菜单、表单格式错误、）";
